Quantitative Trading Analysis Documentation

Setup Environment

The environment setup ensures that all necessary packages for quantitative trading analysis are installed and loaded. This includes packages for data manipulation, financial analysis, plotting, and more.

Data Handling and Analysis

Exploratory Data Analysis (EDA)

Dow Jones and Nasdaq Closing Prices

Closing Prices
Closing Prices

This plot shows the closing prices of the Dow Jones Industrial Average (DJIA) and Nasdaq Composite Index from 2000 to 2024. The blue line represents DJIA, and the red line represents Nasdaq.

Histogram of Daily Returns

Histogram of Daily Returns
Histogram of Daily Returns

The histogram displays the distribution of daily returns for both DJIA and Nasdaq. The blue bars represent DJIA returns, and the red bars represent Nasdaq returns.

Descriptive Statistics for Closing Prices

  • Dow Jones Industrial Average (DJIA)
    • Minimum: 72.06
    • 1st Quartile: 1050.29
    • Median: 13469.16
    • Mean: 13197.92
    • 3rd Quartile: 18230.45
    • Maximum: 28539.45
  • Nasdaq Composite Index (IXIC)
    • Minimum: 1114.11
    • 1st Quartile: 1849.49
    • Median: 3574.54
    • Mean: 3642.76
    • 3rd Quartile: 5297.25
    • Maximum: 8837.45

Descriptive Statistics for Daily Returns

  • DJIA Daily Returns
    • Minimum: -0.0994
    • 1st Quartile: -0.0032
    • Median: 0.0003
    • Mean: 0.0004
    • 3rd Quartile: 0.0037
    • Maximum: 0.1122
  • Nasdaq Daily Returns
    • Minimum: -0.1018
    • 1st Quartile: -0.0041
    • Median: 0.0006
    • Mean: 0.0005
    • 3rd Quartile: 0.0052
    • Maximum: 0.1074

Annual Returns of Dow Jones and Nasdaq

Annual Returns
Annual Returns

This scatter plot illustrates the annual returns of DJIA and Nasdaq. Each point represents the annual return for a given year, with blue points for DJIA and red points for Nasdaq.

Monthly Returns of Dow Jones and Nasdaq

Monthly Returns
Monthly Returns

This scatter plot shows the monthly returns of DJIA and Nasdaq, with blue points representing DJIA and red points representing Nasdaq.

Volatility Analysis

Rolling 30-Day Volatility

Rolling Volatility
Rolling Volatility

The rolling 30-day volatility plot highlights the annualized volatility of DJIA (blue line) and Nasdaq (red line) over time.

Correlation Analysis

Rolling 30-Day Correlation between Dow Jones and Nasdaq Returns

Rolling Correlation
Rolling Correlation

This plot presents the rolling 30-day correlation between the daily returns of DJIA and Nasdaq.

Correlation between Dow Jones and Nasdaq Returns

  • Correlation: 0.679

Cumulative Returns

Cumulative Overnight and Intraday Returns for Nasdaq and Dow Jones

Cumulative Returns
Cumulative Returns

The plot shows the cumulative overnight and intraday returns for both Nasdaq and DJIA. The different colors represent the various return types for each index.

  • Final Cumulative Returns for Dow Jones:
    • Overnight Return: 1.304
    • Intraday Return: 1.874
  • Final Cumulative Returns for Nasdaq:
    • Overnight Return: 2.504
    • Intraday Return: 2.842

Moving Averages

Dow Jones with 50 and 200-Day Moving Averages

DJIA Moving Averages
DJIA Moving Averages

This plot shows the DJIA closing prices along with the 50-day (blue) and 200-day (red) moving averages.

Nasdaq with 50 and 200-Day Moving Averages

Nasdaq Moving Averages
Nasdaq Moving Averages

This plot shows the Nasdaq closing prices along with the 50-day (blue) and 200-day (red) moving averages.

Heatmap of Returns Correlations

Heatmap of Returns Correlations
Heatmap of Returns Correlations

This heatmap visualizes the correlations between the returns of DJIA and Nasdaq over different periods (daily, weekly, monthly).

Seasonal Analysis

Histogram of Monthly Returns for NASDAQ Composite

NASDAQ Monthly Returns Histogram
NASDAQ Monthly Returns Histogram

This histogram shows the distribution of monthly returns for the NASDAQ Composite index, categorized by month.

Density Plot of Quarterly Returns for NASDAQ Composite

NASDAQ Quarterly Returns Density
NASDAQ Quarterly Returns Density

This density plot illustrates the distribution of quarterly returns for the NASDAQ Composite index.

Average Monthly Returns for NASDAQ Composite

NASDAQ Average Monthly Returns
NASDAQ Average Monthly Returns

This bar plot displays the average monthly returns for the NASDAQ Composite index.

Median Monthly Returns for NASDAQ Composite

NASDAQ Median Monthly Returns
NASDAQ Median Monthly Returns

This bar plot shows the median monthly returns for the NASDAQ Composite index.

Performance Based on Sentiment

VIX Index and Market Sentiment

VIX and Market Sentiment
VIX and Market Sentiment

This plot depicts the VIX index and corresponding market sentiment scores over time, with different sentiment zones shaded.

Performance by Sentiment Zone

  • Performance for Dow Jones during various sentiment zones:
    • Very Low:
      • Overnight Return: 0.045
      • Intraday Return: 0.056
      • Total Return: 0.103
    • Low:
      • Overnight Return: 0.038
      • Intraday Return: 0.041
      • Total Return: 0.079
    • Neutral:
      • Overnight Return: 0.021
      • Intraday Return: 0.026
      • Total Return: 0.047
    • High:
      • Overnight Return: 0.011
      • Intraday Return: 0.012
      • Total Return: 0.023
    • Very High:
      • Overnight Return: -0.007
      • Intraday Return: -0.005
      • Total Return: -0.012

Performance Summary for Nasdaq

Performance Summary for Nasdaq
Performance Summary for Nasdaq

This bar plot summarizes the average and median returns for the NASDAQ Composite index across different sentiment zones.

General Correlation

General Correlation between Nasdaq and Dow Jones

  • Correlation: 0.89

Interactive Analysis with Shiny

The Shiny application includes interactive plots for deeper analysis:

Drawdowns of Nasdaq and Dow Jones

Drawdowns
Drawdowns

This interactive plot shows the drawdowns for both Nasdaq and Dow Jones indices.

Relative Performance of Nasdaq vs. Dow Jones

Relative Performance
Relative Performance

This interactive dygraph illustrates the relative performance of the Nasdaq index compared to the Dow Jones index.

Rolling Sharpe Ratio Over Time

Rolling Sharpe Ratio
Rolling Sharpe Ratio

This interactive plot presents the rolling Sharpe ratios for both Nasdaq and Dow Jones.

Volatility (VIX) vs. Market Indices

Volatility vs. Indices
Volatility vs. Indices

This interactive plot compares the VIX index with the market indices (Nasdaq and Dow Jones), normalized to a common scale for better comparison.

Conclusion

This documentation covers the essential steps and visualizations for a comprehensive quantitative trading analysis using R. The analysis includes data handling, exploratory data analysis, volatility and correlation analysis, cumulative returns, moving averages, seasonal returns, sentiment-based performance, and interactive analysis using Shiny.